# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=mythes
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.2.5
pkgrel=1
pkgdesc="MyThes spellchecking library. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url="https://github.com/hunspell/mythes"
msys2_references=(
  'archlinux: libmythes'
)
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-hunspell")
optdepends=("perl: for th_gen_idx.pl script")
source=("https://github.com/hunspell/mythes/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('19279f70707bbe5ffa619f2dc319f888cec0c4a8d339dc0a21330517bd6f521d')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --disable-werror

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"

  make check || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" make install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
